package com.zyy.smartcity1129.zhdj;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.zyy.smartcity1129.BaseFragment;
import com.zyy.smartcity1129.R;
import com.zyy.smartcity1129.data.DYLearnInfo;
import com.zyy.smartcity1129.util.RvAd;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: DYLearn$
 * @Description: 作用
 * @Author: letquit
 * @CreateDate: 12/12/2021$
 * @Version: 1.0
 */
public class DYLearnFragment extends BaseFragment {
    private SearchView search;
    private RecyclerView rvOnly;
    private Button btnNext;
    private Button btnMore;
    private TextView tvOnly;
    public static DYLearnInfo dyLearnInfos;

    @Override
    protected int layId() {
        return R.layout.f_rv_only;
    }

    @Override
    protected String title() {
        return "党员学习";
    }

    @Override
    protected boolean back() {
        return true;
    }

    @Override
    protected Boolean bottom() {
        return null;
    }

    @Override
    protected void init(View iv) {
        initView(iv);
        List<DYLearnInfo> list = new ArrayList<>();
        list.add(new DYLearnInfo("七一建党节 党的生日", R.drawable.dyhd1, 0, R.raw.dyxxvideo01));
        list.add(new DYLearnInfo("群防群治 坚决打赢武汉疫情攻坚战", R.drawable.dyhd2, 0, R.raw.dyxxvideo02));
        list.add(new DYLearnInfo(" 团结一致 坚决打赢武汉疫情攻坚战", R.drawable.dyhd3, 0, R.raw.dyxxvideo03));
        list.add(new DYLearnInfo(" 音频1759", R.drawable.dyhd4, 1, R.raw.dyxx1759));
        rvOnly.setLayoutManager(new LinearLayoutManager(getContext()));
        RvAd<DYLearnInfo> rvAd = new RvAd<DYLearnInfo>(list, R.layout.rv_base) {
            private void initView(View vi) {
                ig = (ImageView) vi.findViewById(R.id.ig);
                view = (View) vi.findViewById(R.id.view);
                lineRvPatient = (LinearLayout) vi.findViewById(R.id.lineRvPatient);
                tv1 = (TextView) vi.findViewById(R.id.tv1);
                tv8 = (TextView) vi.findViewById(R.id.tv8);
                tv2 = (TextView) vi.findViewById(R.id.tv2);
                tv3 = (TextView) vi.findViewById(R.id.tv3);
                tv4 = (TextView) vi.findViewById(R.id.tv4);
                tv5 = (TextView) vi.findViewById(R.id.tv5);
                tv6 = (TextView) vi.findViewById(R.id.tv6);
                tv7 = (TextView) vi.findViewById(R.id.tv7);
                lineRv = (LinearLayout) vi.findViewById(R.id.lineRv);
                add = (ImageView) vi.findViewById(R.id.add);
                num = (TextView) vi.findViewById(R.id.num);
                remove = (ImageView) vi.findViewById(R.id.remove);
                imgRvPatient = (ImageView) vi.findViewById(R.id.imgRvPatient);
                imgDowm = (ImageView) vi.findViewById(R.id.imgDowm);
                rv = (RecyclerView) vi.findViewById(R.id.rv);
                tv2.setVisibility(View.GONE);
                tv3.setVisibility(View.GONE);
                tv4.setVisibility(View.GONE);
                tv5.setVisibility(View.GONE);
            }

            private RecyclerView rv;
            private ImageView imgDowm;
            private ImageView imgRvPatient;
            private ImageView remove;
            private TextView num;
            private ImageView add;
            private LinearLayout lineRv;
            private TextView tv7;
            private TextView tv6;
            private TextView tv5;
            private TextView tv4;
            private TextView tv3;
            private TextView tv2;
            private TextView tv8;
            private TextView tv1;
            private LinearLayout lineRvPatient;
            private View view;
            private ImageView ig;

            @Override
            protected void initR(View vi, DYLearnInfo dyLearnInfo, int p) {
                initView(vi);
                Glide.with(ig.getContext()).load(dyLearnInfo.getImg()).into(ig);
                tv1.setText(dyLearnInfo.getName());
                vi.setOnClickListener(view1 -> {
                    dyLearnInfos = dyLearnInfo;
                    add(new DYLearn1Fragment());
                });
            }
        };
        rvOnly.setAdapter(rvAd);
    }

    private void initView(View iv) {
        search = (SearchView) iv.findViewById(R.id.search);
        rvOnly = (RecyclerView) iv.findViewById(R.id.rvOnly);
        btnNext = (Button) iv.findViewById(R.id.btnNext);
        btnMore = (Button) iv.findViewById(R.id.btnMore);
        tvOnly = (TextView) iv.findViewById(R.id.tvOnly);
    }
}
